<?php

class ResourceManager extends PObject { 
	private $_resource = array();
		
	public function __construct() { 
	
	}
	
	public function __destruct() {
		foreach ($this->_resource as $key => $value) { 
			$this->deleteResource($key);
		}
		unset($this->_resource);
	}

	public function setResource($key, $type, $data) { 
		if (!array_key_exists($key, $this->_resource)) {

			if ($type == 'image') { 
				$resource = WBImage::loadFile($data);	
			} else if ($type == 'font') { 
				$resource = new WBFont($data[0], $data[1], $data[2], $data[3]);
			}
			
			$this->_resource[$key] = $resource; 
		} 
	}
	
	public function getResource($key) { 
		return $this->_resource[$key];
	}
	
	public function deleteResource($key) { 
		unset($this->_resource[$key]);
	}
}


?>